﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class Lesson2 : MonoBehaviour
{
    public Rect musicRect;
    public GUIStyle musicStyle;

    bool musicState = false;
    bool soundState = false;

    public Rect closeRect;
    public GUIStyle closeStyle;

    public Rect musicVolumeRect;
    float musicVolume = 0.5f;
    float soundVolume = 0.5f;

    public static Lesson2 Instance;


    public Rect backGroundRect;
    public Texture2D backGroundImage;
    public ScaleMode scaleMode;
    public bool alpha;
    public float aspect;

    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
        }

        Instance = this;
        Hide();
    }

    private void OnGUI()
    {
        GUI.DrawTexture(backGroundRect, backGroundImage, scaleMode, alpha, aspect); 

        //开启/禁用 音乐 状态
        musicState = GUI.Toggle(musicRect, musicState, "音乐", musicStyle);
        //第二参数为 当前拖动条的值
        //第三、四参数分别为 左值和右值
        musicVolume = GUI.HorizontalSlider(musicVolumeRect, musicVolume, 0f, 1f);

        
        Rect soundRect = new Rect(musicRect);
        soundRect.y += 150;
        soundState = GUI.Toggle(soundRect, soundState, "音效", musicStyle);
        Rect soundVolumeRect = new Rect(musicVolumeRect);
        soundVolumeRect.y += 150;
        soundVolume = GUI.HorizontalSlider(soundVolumeRect, soundVolume, 0f, 1f);

        if (GUI.Button(closeRect, "", closeStyle))
        {
            Hide();
            lesson1.Instance.Show();
        }


    }

    public  void Show()
    {
        gameObject.SetActive(true);
    }

    public  void Hide()
    {
        gameObject.SetActive(false);
    }
}
